#include "widget.h"
#include "ui_widget.h"

root_widget::root_widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::root_widget)
{
    ui->setupUi(this);

    // 设置水平头
    ui->tree_widget->setHeaderLabels(QStringList() << "英雄" << "英雄介绍");

    // 设置顶层节点
    QTreeWidgetItem *item1 = new QTreeWidgetItem(QStringList() << "力量" << "速度");
    QTreeWidgetItem *item2 = new QTreeWidgetItem(QStringList() << "敏捷");
    QTreeWidgetItem *item3 = new QTreeWidgetItem(QStringList() << "智力" << "IQ" << "IT");

    ui->tree_widget->addTopLevelItem(item1);
    ui->tree_widget->addTopLevelItem(item2);
    ui->tree_widget->addTopLevelItem(item3);

    // 追加子节点
    QStringList string_list_01;
    string_list_01 << "诸葛亮" << "后排法师";
    QTreeWidgetItem *child_item = new QTreeWidgetItem(string_list_01);
    item1->addChild(child_item);
}

root_widget::~root_widget()
{
    delete ui;
}

